package com.kantboot.system.user.setting;

import com.kantboot.system.user.service.ISysUserOnlineService;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system-user-web/userOnline")
public class SysUserOnlineController {

    @Resource
    private ISysUserOnlineService service;

    /**
     * 用户在线
     */
    @RequestMapping("/online")
    public RestResult<Void> online(@RequestParam("userId") Long userId){
        service.online(userId);
        return RestResult.success(null,"onlineSuccess","用户在线成功");
    }

    /**
     * 用户下线
     */
    @RequestMapping("/offline")
    public RestResult<Void> offline(@RequestParam("userId") Long userId){
        service.offline(userId);
        return RestResult.success(null,"offlineSuccess","用户下线成功");
    }


    /**
     * 心跳
     */
    @RequestMapping("/heartbeat")
    public RestResult<Void> heartbeat(@RequestParam("userId") Long userId){
        service.heartbeat(userId);
        return RestResult.success(null,"heartbeatSuccess","心跳成功");
    }

}
